{{extend './base.html'}}
{{block 'titleBlock'}}购物车页面{{/block}}
{{block 'scriptBlock'}}
<script type="text/javascript" src="/js/web_commodity_pay.js"></script>
{{/block}}
{{block 'contentBlock'}}
<div class="container">
    <div class="container_address">
        <select name="" id="" class="address_select">
            {{if receiving_address}}
            {{each receiving_address}}
            <option value="{{$value.address_id}}">
                <div>
                    <p>地址：{{$value.address}}</p>
                    <p>----- 收货人：{{$value.user_name}}</p>
                    <p>----- 电话：{{$value.phone}}</p>
                </div>
            </option>
            {{/each}}
            {{else}}
            <option value="">
                <div>
                    <p>您还没有添加地址！</p>
                </div>
            </option>
            {{/if}}
        </select>
    </div>
    <div class="shopping_cart">
        <!-- 购买支付表单 -->
        <form>
            <table>
                <tr>
                    <th class="cart_left">
                        <input type="checkbox" name="" id="select">
                        全选
                    </th>
                    <th>商品</th>
                    <th>单价</th>
                    <th>数量</th>
                    <th>小计</th>
                    <th>操作</th>
                </tr>
                {{each indent}}
                <tr>
                    <td class="cart_left"><input type="checkbox" name="selected" class="indent_id{{$index}}" indent_id="{{$value.indent_id}}"></td>
                    <td class="cart_left">
                        <img src="{{$value.commodity_url}}" alt="">
                        {{$value.commodity_name}}
                    </td>
                    <td class="unit_price{{$index}}">￥<em>{{$value.unit_price}}</em></td>
                    <td>
                        <img src="/images/del.jpg" alt="" class="img_del{{$index}} add_del">
                        <span class="number{{$index}}">{{$value.number}}</span>
                        <img src="/images/add.jpg" alt="" class="img_add{{$index}} add_del">
                    </td>
                    <td>￥<span class="price{{$index}}">{{$value.price}}</span></td>
                    <td><a href="javascript:;" class="cart_del" indent_id="{{$value.indent_id}}">删除</a></td>
                </tr>
                <script>
                    //
                    //购物车减购买数量
                    $(".img_del{{$index}}").click(function(){
                        var num=$(".number{{$index}}").html()
                        num=Number(num)-1
                        if(num<1){
                            num=1
                        }
                        $(".number{{$index}}").html(num)
                        cart_price({{$index}})
                    })
                    //购物车加购买数量
                    $(".img_add{{$index}}").click(function(){
                        var num=$(".number{{$index}}").html()
                        num=Number(num)+1
                        if(num>100){
                            num=100
                        }
                        $(".number{{$index}}").html(num)
                        cart_price({{$index}})
                    })
                </script>
                {{/each}}
            </table>
            <div class="orders">
                <a href="javascript:;">清理购物车</a>
                <p>已选择<span class="orders_num">0</span>件商品</p>
                <em>总价：￥<span class="orders_price">0.00</span></em>
                <button type="submit">支付</button>
            </div>
        </form>
    </div>
</div>
{{/block}}